package com.sky.mapper;

import com.sky.dto.DishDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    /**
     * 动态sql查询
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> listShoppingCart(ShoppingCart shoppingCart);

    /**
     * 根据id修改商品数量
     * @param shoppingCart
     */
    void updateCartNumberById(ShoppingCart shoppingCart);

    /**
     * 新增购物车
     * @param shoppingCart
     */
    void insertShoppingCart(ShoppingCart shoppingCart);

    /**
     * 根据菜品id修改购物车商品数量
     * @param shopping
     */
    @Update("update shopping_cart set number = #{number} where dish_id = #{dishId}")
    void updateCartNumberByDishId(ShoppingCart shopping);

    /**
     * 动态删除购物车商品数量
     * @param shopping
     */
    void deleteShoppingCart(ShoppingCart shopping);

    /**
     * 根据dishId修改购物车中的菜品信息
     * @param dishDTO
     */
    void updateCartByDishId(DishDTO dishDTO);
}
